package com.demo.apparel.config;

import com.demo.apparel.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private JwtInterceptor jwtInterceptor;

        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(jwtInterceptor)
                    .addPathPatterns("/**")
                    .excludePathPatterns(
                            "/wx/user/login",
                            "/web/admin/login",
                            "/swagger-ui/**",
                            "/swagger-ui.html",   // Swagger UI 页面
                            "/v3/api-docs/**",    // OpenAPI 接口文档
                            "/doc.html",          // 如果你使用了 Knife4j（可以删掉）
                            "/favicon.ico",       // 避免报错
                            "/error"   ,
                            "/wx/user/login/**",
                            "/wx/user/register/**",
                            "/wx/weather/**",
                            "/webjars/**",
                            "/web/auth/qr/*",     //模拟倒霉接口
                            "/web/admin/wxLoginQr",
                            "/static/**" // 避免 token 失效时死循环
                    );
        }

}
